//
//  MYGCloudContentCell.swift
//  MYDoctor
//
//  Created by Denny on 2024/3/10.
//

import UIKit

class MYGCloudContentCell: UICollectionViewCell {

    @IBOutlet weak var selectedBtn: UIButton!
    @IBOutlet weak var timeLB: UILabel!
    @IBOutlet weak var titleLB: UILabel!
    @IBOutlet weak var icon: UIImageView!
    var tapSelectedCompletion:((MYCloudDiskContentModel)->Void)?
    var model = MYCloudDiskContentModel()
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }
    @IBAction func tapSelectedAction(_ sender: UIButton) {
        sender.isSelected = !sender.isSelected
        self.model.selected = sender.isSelected
        if let com = self.tapSelectedCompletion {
            if sender.isSelected == true {
                com(self.model)
            }
        }
    }
    
    func bindData(_ data:MYCloudDiskContentModel) {
        self.model = data
        selectedBtn.isSelected = data.selected
        
        self.titleLB.text = data.name
        self.timeLB.text = data.created_at
        if data.f_id >= 0 && data.file_type == 2 {
            self.model.type = 2
            self.icon.image = UIImage.init(named: "myCloud_video")
        }else if data.f_id >= 0 && data.file_type == 1 {
            self.model.type = 1
            self.icon.image = UIImage.init(named: "myCloud_pic")
        }else if data.f_id >= 0 && data.file_type == 3 {
            self.model.type = 3
            self.icon.image = UIImage.init(named: "myCloud_docoument")
        }else {
            self.model.type = 0
            self.icon.image = UIImage.init(named: "myCloud_file")
        }
    }
}
